
#include "project.h"

int main()
{
	unsigned char k[16];
	unsigned char iv[32];

	AES_KEY enc, dec;

	assert(RAND_bytes(k, 16) == 1);
	assert(RAND_bytes(iv, 16) == 1);
	memmove(&iv[16], iv, 16);

	assert(AES_set_encrypt_key(k, 128, &enc) == 0);
	assert(AES_set_decrypt_key(k, 128, &dec) == 0);

	unsigned char in[16] = "Hello world!\n";
	unsigned char out1[16];
	unsigned char out2[16];

	AES_cbc_encrypt(in, out1, 16, &enc, iv, AES_ENCRYPT);
	AES_cbc_encrypt(out1, out2, 16, &dec, &iv[16], AES_DECRYPT);

	for (int i = 0; i < 16; i++)
		printf("%x ", in[i]);
	printf("\n");
	for (int i = 0; i < 16; i++)
		printf("%x ", out1[i]);
	printf("\n");
	for (int i = 0; i < 16; i++)
		printf("%x ", out2[i]);
	printf("\n");

	

	return 0;
}
